//
// Created by LH on 2017/8/29.
//

#include <iostream>

using namespace std;


int e[50][50];
bool book[50];
int n;
int sum = 0;
void dfs(int cnt)
{
    if (sum++ == n)
        return;
    cout << cnt << " ";
    for (int t = 1; t <= n; ++t) {
        if (!book[t] && e[cnt][t] == 1)
        {
            book[t] = true;
            dfs(t);
        }
    }
    return;
}
int main()
{
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= n; ++j) {
            cin >> e[i][j];
        }
    }

    book[1] = true;
    dfs(1);
    return 0;
}

/*
5
0 1 1 2 1
1 0 2 1 2
1 2 0 2 1
2 1 2 0 2
1 2 1 2 0
*/